<%-- 
    Document   : login
    Created on : Feb 19, 2012, 9:13:58 PM
    Author     : bluesky
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<!DOCTYPE html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Đăng Nhập</title>

        <link href="css/login-box.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
        
    </head>
<script>
        $(document).ready(function(){            
            show_error("<%= request.getAttribute("errorMessage")%>");                 
        });
    </script>
    <script type="text/javascript">
       
           
        function show_error(val)
        {   
            if(val != "null")
            {
                var msgErr = val.toString();
                if(msgErr != "" && msgErr!="1"){
                    if(msgErr != "-1") {
                        alert(msgErr);
                    }
                    else{
                        alert("Data error!!!")
                    }                                        
                }                                    
                else
                    return false;
            }
            else{
                return false;
            }
        }                   
                            
        function validateForm()
        {
            var x=$("#username").val();
            var y=$("#password").val();
            var msgErr ="";
            if (x==null || x=="")
            {
                msgErr = "User name must be filled out";                
            }
            if (y==null || y=="")
            {
                msgErr = msgErr + "\nPassword must be filled out";                
            }
            if(y!="" && y.toString().length < 6)
            {
                msgErr = msgErr + "\nPassword can not be less than 6 characters.";
            }
            if(msgErr != ""){
                alert(msgErr);
                return false;
            }                
        }
        
    </script>
    <body>


        <div style="padding: 100px 0 0 250px;">


            <div id="login-box">

                <H2>Đăng nhập</H2>
                <%
                request.removeAttribute("errorMessage");
                %>
                <br />
                <br />
                <html:form action="/login">
                <div id="login-box-name" style="margin-top:20px;">Tài khoản:</div>
                <div id="login-box-field" style="margin-top:20px;">
                    <!--<input name="username" class="form-login" title="username" value="" size="30" maxlength="2048" />-->
                    
                    <html:text property="username" size="30" maxlength="2048" styleId="username" styleClass="form-login" />
                    
                 </div>
                <div id="login-box-name">Mật khẩu:</div>
                <div id="login-box-field">
                    <input name="password" type="password" class="form-login" title="password" value="" size="30" maxlength="2048" id="password"/>
                    
                        
                </div>
                <br />
                <span class="login-box-options"><input type="checkbox" name="1" value="1"> Remember Me <a href="#" style="margin-left:30px;">Đăng ký</a></span>
                <br />
                <br />
                <html:submit value="Đăng nhập" onclick="return validateForm()"><img src="../images/login-btn.png" width="103" height="42" style="margin-left:90px;" /></html:submit>
                </html:form> 
            </div>
        </div>
    </body>
</html>

